#include "basewindow.h"
#include "mainmenu.h"
#include "ui_mainmenu.h"

MainMenu::MainMenu(QWidget *parent, QString newFilepath) :
    QWidget(parent),
    ui(new Ui::MainMenu)
{
    ui->setupUi(this);

    this->filepath = newFilepath;

    //Create Background Image
    QString background = newFilepath + "Images/menubg.png";
    qDebug() << "mainMenu background: " << background << endl;
    bg = QImage(background);
}

MainMenu::~MainMenu()
{
    delete ui;
}

void MainMenu::on_newGame_clicked()
{
    dynamic_cast<BaseWindow*>(this->parent())->showMainWindow("new game");
    this->deleteLater();
}

void MainMenu::on_loadGame_clicked()
{
    dynamic_cast<BaseWindow*>(this->parent())->showMainWindow("load game");
    this->deleteLater();
}

void MainMenu::paintEvent(QPaintEvent *event)
{
    //Create the painter
    QPainter painter(this);

    //Draw background image
    //painter.setBrush(QBrush(Qt::white, Qt::SolidPattern));
    QRect imageRect(0,0,this->width(), this->height());
    painter.drawImage(imageRect, bg);

    painter.end();
}
